---
title: Remark Docs Generation
description: Useful remark plugins to generate docs automatically
---

## Usage

```package-install
fumadocs-docgen
```

Add the remark plugin.

```ts title="source.config.ts" tab="Fumadocs MDX"
import { remarkDocGen, fileGenerator } from 'fumadocs-docgen';
import { defineConfig } from 'fumadocs-mdx/config';

export default defineConfig({
  mdxOptions: {
    remarkPlugins: [[remarkDocGen, { generators: [fileGenerator()] }]],
  },
});
```

```ts tab="MDX Compiler"
import { remarkDocGen, fileGenerator } from 'fumadocs-docgen';
import { compile } from '@mdx-js/mdx';

await compile('...', {
  remarkPlugins: [[remarkDocGen, { generators: [fileGenerator()] }]],
});
```

## File Generator

It copies the content from a file to the document (mdast tree) and forms a paragraph.

````mdx
```json doc-gen:file
{
  "file": "./my/file.txt"
}
```
````

### As Code Block

Copy the content into a code block.

````mdx
```json doc-gen:file
{
  "file": "./my/file.txt",
  "codeblock": true
}
```
````

Or to specify the programming language and meta string:

````mdx
```json doc-gen:file
{
  "file": "./my/file.txt",
  "codeblock": {
    "lang": "ts",
    "meta": "title=\"Hello\""
  }
}
```
````
